package com.asynctm.android.socialnetwork.activity;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.asynctm.android.R;
import com.asynctm.android.socialnetwork.dto.ContactDto;

/**
 * Mantiene referencias a las vistas que componen un elemento de la lista de
 * contactos
 * 
 * @author rockdrigo
 */
public class ContactListItemViewHolder {

	private ImageView contactPhoto;
	private TextView lblName;

	public ContactListItemViewHolder(View parent) {
		super();
		contactPhoto = (ImageView) parent.findViewById(R.id.contactPhoto);
		lblName = (TextView) parent.findViewById(R.id.lblName);
	}

	public TextView getLblName() {
		return lblName;
	}

	public void populate(ContactDto contact) {
		lblName.setText(contact.getName());
		if (contact.getPhoto() != null) {
			contactPhoto.setImageBitmap(contact.getPhoto());
		}else{
			contactPhoto.setImageResource(R.drawable.ic_launcher);
		}
	}

}
